#include <stdio.h>

int (*findScore(int score[][5],int index))[5]{
    int (*p)[5]=score;
    while (*p){
        if (*(p[0]+0) == index) {
            return p;
        }
        p++;
    }
    return NULL;
}

void printScore(int n,int score[][5]){
    int (*q)[5]=score;
    while (*q<score[n]){
        printf("%d %d %d %d %d\n",q[0][0],q[0][1],q[0][2],q[0][3],q[0][4]);
        q++;
    }
    return;
}
void main(){
    int n;
    scanf("%d", &n);
    int score[n][5];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            scanf("%d", &score[i][j]);
        }
    }
    int index;
    scanf("%d", &index);
    

    int (*p)[5]=findScore(score,index);
    if (*p){
        printf("%d %d %d %d\n",p[0][1],p[0][2],p[0][3],p[0][4]);
    }
    printScore(n,score);
}